/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package HumanCentredSystemDesign;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;

/**
 *
 * @author Tim Archer
 */
public class AssortedTests {
    public static void main(String args []) {
        Connect con = new Connect();
        con.establishConnection();
 
        /*insertion string:
        INSERT INTO `hcsd3`.`Reservations` (`reservationDate`, `itemIdentifier`, `libraryMemberID`) VALUES ('2011-12-07', '0747558191', '10001104');
        INSERT INTO `hcsd3`.`Reservations` (`reservationDate`, `itemIdentifier`, `libraryMemberID`) VALUES ('2011-12-07', '0747562180', '10001104');
        INSERT INTO `hcsd3`.`Reservations` (`reservationDate`, `itemIdentifier`, `libraryMemberID`) VALUES ('2011-12-07', '074757376X', '10001104');
        INSERT INTO `hcsd3`.`Reservations` (`reservationDate`, `itemIdentifier`, `libraryMemberID`) VALUES ('2011-12-07', '0747582386', '10001104');
        INSERT INTO `hcsd3`.`Reservations` (`reservationDate`, `itemIdentifier`, `libraryMemberID`) VALUES ('2011-12-07', '0747591261', '10001104');
        INSERT INTO `hcsd3`.`Reservations` (`reservationDate`, `itemIdentifier`, `libraryMemberID`) VALUES ('2011-12-07', '1443458X', '10001104');
        INSERT INTO `hcsd3`.`Reservations` (`reservationDate`, `itemIdentifier`, `libraryMemberID`) VALUES ('2011-12-07', '1443459X', '10001104');*/


        ArrayList<Reservation> reservationList = con.getReservationsFromDatabase("", "");
        //for (Reservation r : reservationList){
        //    r.toString();
        //}

        /*ArrayList<Loan> loanList = con.getLoansFromDatabase("10001101","");
        for (Loan l : loanList){
            l.toString();
        } 
         */
        Reservation myReservation = reservationList.get(0);
        Reservation myReservation2 = reservationList.get(1);
        Item myItem = myReservation.getReservedItem();
        System.out.println(myItem);
        Item myItem2 = myReservation2.getReservedItem();
        System.out.println(myItem2);
        /*Loan testLoan = loanList.get(0);
        System.out.println(loanList.isEmpty());
        testLoan.toString();
        System.out.println("Day: "+testLoan.getIssueDate().getDate());
        System.out.println("Month: "+testLoan.getIssueDate().getMonth());
        System.out.println("Year: "+(testLoan.getIssueDate().getYear()+1900));*/


           SimpleDateFormat formatter;
           formatter = new SimpleDateFormat("yyyy-MM-dd");
           Date myDate = new Date();
           String myDateString = formatter.format(myDate);

           try{
               Date myDate2 = formatter.parse(myDateString);
               System.out.println(myDate.getTime());
               System.out.println(myDate2.getTime());
               long timeDiffMs = myDate.getTime() - myDate2.getTime();
               int timeDiffSec = (int) (timeDiffMs/1000);
               int timeDiffMin = timeDiffSec/60;
               int timeDiffHour = timeDiffMin/60;
               System.out.println(timeDiffHour);
           }
           catch(ParseException ex){
               System.out.println(ex.toString());
           }
           
           Date myReservationDate = myReservation.getReservationDate();
           System.out.println(myReservationDate.getTime());
           
           DischargeManager dm = new DischargeManager();
           dm.dischargeCopy("500.11.1");


        /*Reservation testReservation = reservationList.get(0);

        //con.CancelReservationFromDatabase(testReservation);

        //testReservation.removeReservationFromDatabase();

       Calendar now =  Calendar.getInstance();
       Calendar issued = Calendar.getInstance();
       Calendar issued2 = Calendar.getInstance();
       issued.set(testLoan.getIssueDate().getYear()+1900, testLoan.getIssueDate().getMonth(), testLoan.getIssueDate().getDate()+testLoan.getLoanPeriod());
       issued2.set(testLoan.getIssueDate().getYear()+1900, testLoan.getIssueDate().getMonth(), testLoan.getIssueDate().getDate()-1);

       System.out.println(now);
       System.out.println(issued);
       System.out.println(issued2);
       System.out.println(now.after(issued));
       System.out.println(now.after(issued2));*/
        
        /*ArrayList<Copy> myCopies = con.getItemCopiesFromDatabase("100.11.1", "");
        Copy myCopy = myCopies.get(0);
        System.out.println(myCopy);
        Item myItem = myCopy.getLoanedItem();
        System.out.println(myItem);
        
        LibraryCirculations lc = new LibraryCirculations();
        Item myOtherItem = lc.getItemFromCopy(myCopy);
        System.out.println(myOtherItem);*/

        con.closeConnection();
    }
}
